﻿using System.CodeDom;
using System.CodeDom.Compiler;
using System.Diagnostics;
using System.Reflection;
using SmartStringResources.CodeDom;

namespace SmartStringResources
{
    static class CodeTypeBuildersHelpers
    {
        public static TypeAttributes GetTypeAttribute(this AccessibilityLevel accessibilityLevel)
        {
            if (accessibilityLevel == AccessibilityLevel.Internal)
                return TypeAttributes.NestedFamANDAssem;

            // if Public or Default
            return TypeAttributes.Public;
        }

        public static void AddDefaultAttributes(this CodeTypeDeclaration codeClass)
        {
            var assemblyName = typeof(SmartStringResourcesGenerator).Assembly.GetName();
            codeClass.CustomAttributes.AddAttribute(typeof(GeneratedCodeAttribute), assemblyName.Name, assemblyName.Version.ToString(3));
            codeClass.CustomAttributes.AddAttribute(typeof(DebuggerNonUserCodeAttribute));
        }
    }
}